package cn.iocoder.yudao.module.erp.dal.mysql.dp;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.dp.dpsign.vo.DpSignPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.dp.DpSignDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


/**
 * 配送后程 Mapper
 * @author 天使管理员
 */
@Mapper
public interface DpSignMapper extends BaseMapperX<DpSignDO> {

    default PageResult<DpSignDO> selectPage(DpSignPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DpSignDO>()
                .likeIfPresent(DpSignDO::getDpId, reqVO.getDpId())
                .eqIfPresent(DpSignDO::getNo, reqVO.getNo())
                .eqIfPresent(DpSignDO::getStoreType, reqVO.getStoreType())
                .likeIfPresent(DpSignDO::getInName, reqVO.getInName())
                .eqIfPresent(DpSignDO::getDispatchNumber, reqVO.getDispatchNumber())
                .eqIfPresent(DpSignDO::getInCount, reqVO.getInCount())
                .eqIfPresent(DpSignDO::getRemCount, reqVO.getRemCount())
                .eqIfPresent(DpSignDO::getInVolume, reqVO.getInVolume())
                .eqIfPresent(DpSignDO::getRemVolume, reqVO.getRemVolume())
                .eqIfPresent(DpSignDO::getWeight, reqVO.getWeight())
                .eqIfPresent(DpSignDO::getRemWeight, reqVO.getRemWeight())
                .eqIfPresent(DpSignDO::getArrCount, reqVO.getArrCount())
                .eqIfPresent(DpSignDO::getArrVolume, reqVO.getArrVolume())
                .eqIfPresent(DpSignDO::getArrWeight, reqVO.getArrWeight())
                .betweenIfPresent(DpSignDO::getArrivedTime, reqVO.getArrivedTime())
                .eqIfPresent(DpSignDO::getTotalNote, reqVO.getTotalNote())
                .eqIfPresent(DpSignDO::getDensity, reqVO.getDensity())
                .eqIfPresent(DpSignDO::getDeliveryPhone, reqVO.getDeliveryPhone())
                .likeIfPresent(DpSignDO::getDeliveryName, reqVO.getDeliveryName())
                .eqIfPresent(DpSignDO::getEarpayAmount, reqVO.getEarpayAmount())
                .eqIfPresent(DpSignDO::getInPic, reqVO.getInPic())
                .eqIfPresent(DpSignDO::getLine, reqVO.getLine())
                .eqIfPresent(DpSignDO::getWay, reqVO.getWay())
                .eqIfPresent(DpSignDO::getGoodsValue, reqVO.getGoodsValue())
                .eqIfPresent(DpSignDO::getPremium, reqVO.getPremium())
                .eqIfPresent(DpSignDO::getGuaranteedRate, reqVO.getGuaranteedRate())
                .eqIfPresent(DpSignDO::getWriteOff, reqVO.getWriteOff())
                .eqIfPresent(DpSignDO::getWriteExpenses, reqVO.getWriteExpenses())
                .eqIfPresent(DpSignDO::getDiscountAmount, reqVO.getDiscountAmount())
                .eqIfPresent(DpSignDO::getFile, reqVO.getFile())
                .eqIfPresent(DpSignDO::getNote, reqVO.getNote())
                .eqIfPresent(DpSignDO::getShipper, reqVO.getShipper())
                .eqIfPresent(DpSignDO::getDestination, reqVO.getDestination())
                .eqIfPresent(DpSignDO::getConsignee, reqVO.getConsignee())
                .eqIfPresent(DpSignDO::getAdvancePayPack, reqVO.getAdvancePayPack())
                .eqIfPresent(DpSignDO::getAdvancePayPackUp, reqVO.getAdvancePayPackUp())
                .eqIfPresent(DpSignDO::getAdvancePayChinaFreight, reqVO.getAdvancePayChinaFreight())
                .eqIfPresent(DpSignDO::getAdvancePayForGoods, reqVO.getAdvancePayForGoods())
                .eqIfPresent(DpSignDO::getCollecting, reqVO.getCollecting())
                .eqIfPresent(DpSignDO::getCustomerRebate, reqVO.getCustomerRebate())
                .eqIfPresent(DpSignDO::getBusinessRebate, reqVO.getBusinessRebate())
                .eqIfPresent(DpSignDO::getStatus, reqVO.getStatus())
                .eqIfPresent(DpSignDO::getPayType, reqVO.getPayType())
                .eqIfPresent(DpSignDO::getSalesman, reqVO.getSalesman())
                .eqIfPresent(DpSignDO::getUnitPrice, reqVO.getUnitPrice())
                .eqIfPresent(DpSignDO::getCubeUnitPrice, reqVO.getCubeUnitPrice())
                .eqIfPresent(DpSignDO::getCalmethod, reqVO.getCalmethod())
                .eqIfPresent(DpSignDO::getTotalAmount, reqVO.getTotalAmount())
                .eqIfPresent(DpSignDO::getIsSplit, reqVO.getIsSplit())
                .eqIfPresent(DpSignDO::getInventoryStatus, reqVO.getInventoryStatus())
                .eqIfPresent(DpSignDO::getPickStatus, reqVO.getPickStatus())
                .eqIfPresent(DpSignDO::getReceivedFare, reqVO.getReceivedFare())
                .eqIfPresent(DpSignDO::getDebtTotal, reqVO.getDebtTotal())
                .eqIfPresent(DpSignDO::getClaimAmount, reqVO.getClaimAmount())
                .betweenIfPresent(DpSignDO::getChooseDate, reqVO.getChooseDate())
                .eqIfPresent(DpSignDO::getIsPoint, reqVO.getIsPoint())
                .eqIfPresent(DpSignDO::getIsWriteOff, reqVO.getIsWriteOff())
                .eqIfPresent(DpSignDO::getNotPoint, reqVO.getNotPoint())
                .eqIfPresent(DpSignDO::getNotWriteOff, reqVO.getNotWriteOff())
                .eqIfPresent(DpSignDO::getSignStatus, reqVO.getSignStatus())
                .betweenIfPresent(DpSignDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DpSignDO::getId));
    }

    @Select("SELECT SUM(sign_num) AS signNum FROM erp_dp_sign WHERE dp_id = #{id}")
    Integer getSumSignNum(@Param("id") String id);

}